package com.example.hanchen.yongkanggy.home.fragment;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;

import com.example.hanchen.yongkanggy.R;
import com.example.hanchen.yongkanggy.home.adapter.FragmentListAdapter;
import com.example.hanchen.yongkanggy.home.adapter.MyAdapter;
import com.example.hanchen.yongkanggy.home.adapter.WarnItemAdapter;
import com.example.hanchen.yongkanggy.home.base.BaseFragment;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import java.util.ArrayList;
import java.util.List;

/*
* 预警主界面
* */
public class WarnFragment extends BaseFragment {

    TabLayout tabLayout;
    ViewPager viewPager;


    public static WarnFragment newInstance() {
        Bundle args = new Bundle();
        WarnFragment fragment = new WarnFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @SuppressLint("MissingInflatedId")
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_warn, container, false);
        tabLayout = view.findViewById(R.id.tl_tablayout);
        viewPager = view.findViewById(R.id.view_pager);

        initData(view);
        return view;
    }

    private void initData(View view) {

        List<Fragment> frameLayoutList = new ArrayList<Fragment>();
        frameLayoutList.add(new WarnitemFragment());
        frameLayoutList.add(new WarnitemFragment());
        frameLayoutList.add(new WarnitemFragment());

        List<String> tabLayoutList = new ArrayList<>();
        tabLayoutList.add("全部");
        tabLayoutList.add("重点人员");
        tabLayoutList.add("流动人员");


        WarnItemAdapter adapter = new WarnItemAdapter(getChildFragmentManager(), frameLayoutList, tabLayoutList);

        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
        viewPager.setOffscreenPageLimit(2);


    }
}
